using System;

namespace Metar.NET
{
    public class WindDir
    {
        public const double VRB = -1;
        public double var_beg = 0;
        public double var_end = 0;
        public double deg = 0;
        
        public WindDir()
        {

        }
    }

	public class Wind:WeatherInformation
	{
        private const string wind_vrb_image = "vrb.png";
        private const string wind_nodir_image = "nodir.png";
        private const string wind_nodata_image = "wind_nodata.png";
        private string[] wind_dir_images=new string[]{  "nnn.png",
                                                        "nne.png",
                                                        "ne.png",
                                                        "nee.png",
                                                        "eee.png",
                                                        "see.png",
                                                        "se.png",
                                                        "sse.png",
                                                        "sss.png",
                                                        "ssw.png",
                                                        "sw.png",
                                                        "sww.png",
                                                        "www.png",
                                                        "nww.png",
                                                        "nw.png",
                                                        "nnw.png",
                                                        "nnn.png"
                                                     };

        public WindSpeed speed = null;
        public WindSpeed gust_speed = null;
        public WindDir direction = null;

		public Wind()
		{
            this.speed = new WindSpeed();
            this.gust_speed = new WindSpeed();
            this.direction = new WindDir();
		}

        public string get_winddir_image()
        {
            if (this.b_no_data)
                return Wind.wind_nodata_image;

            // wind variable
            if (this.direction.deg == WindDir.VRB)
            {
                return Wind.wind_vrb_image;
            }
            else if ((this.direction.deg == 0) && (this.speed.Knots == 0))
            {
                return Wind.wind_nodir_image;
            } 
            else
            {
                string str_ret=this.wind_dir_images[(int)(System.Math.Round(this.direction.deg/22.5))];
                if (str_ret == null)
                    str_ret = String.Empty;
                return str_ret;
            }
        }
	}
}
